/**
 * 分页读取结果
 */
package com.mavenq.fly.utils.excelv4.model;

import java.util.List;

public class PageReadResult<T> {
    private final List<T> data;
    private final int currentPage;
    private final int pageSize;
    private final int totalPages;
    private final long totalRows;
    private final boolean hasNext;
    private final ImportResult<T> importResult;

    public PageReadResult(List<T> data, int currentPage, int pageSize, 
                         long totalRows, ImportResult<T> importResult) {
        this.data = data;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalRows = totalRows;
        this.totalPages = (int) Math.ceil((double) totalRows / pageSize);
        this.hasNext = currentPage < totalPages;
        this.importResult = importResult;
    }
    
    // Getter方法
    public List<T> getData() { return data; }
    public int getCurrentPage() { return currentPage; }
    public int getPageSize() { return pageSize; }
    public int getTotalPages() { return totalPages; }
    public long getTotalRows() { return totalRows; }
    public boolean hasNext() { return hasNext; }
    public ImportResult<T> getImportResult() { return importResult; }
    
    /**
     * 获取读取进度
     */
    public double getProgress() {
        if (totalRows == 0) return 100.0;
        return Math.min(100.0, (currentPage * pageSize * 100.0) / totalRows);
    }
}